package cn.outsourcing.supermarket.converter;

import cn.outsourcing.supermarket.converter.transform.BooleanToIntegerTransform;
import cn.outsourcing.supermarket.po.HiolabsCategory;
import cn.outsourcing.supermarket.po.HiolabsGoods;
import cn.outsourcing.supermarket.vo.CategoryGoodsVO;
import cn.outsourcing.supermarket.vo.foot.FootGoodsVO;
import cn.outsourcing.supermarket.vo.hiolabs.HiolabsGoodsVO;
import cn.outsourcing.supermarket.vo.home.HomeCategoryListVO;
import cn.outsourcing.supermarket.vo.home.HomeGoodsListVO;
import org.mapstruct.IterableMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 商品实体类映射器
 *
 * @author gzkemays
 * @since 2021/10/21 19:42
 */
@Mapper(uses = {BooleanToIntegerTransform.class})
public interface HiolabsGoodsConverter {
  HiolabsGoodsConverter INSTANCE = Mappers.getMapper(HiolabsGoodsConverter.class);
  //    @Mappings({
  //            @Mapping(source = "id", target = "id"),
  //            @Mapping(source = "name", target = "name"),
  //            @Mapping(source = "goodsNumber", target = "goodsNumber"),
  //            @Mapping(source = "minRetailPrice", target = "minRetailPrice"),
  //            @Mapping(source = "goodsBrief", target = "goodsBrief"),
  //            @Mapping(source = "listPicUrl", target = "listPicUrl")
  //    })

  /**
   * 映射返回 {@link CategoryGoodsVO}
   *
   * @param goods po 数据
   * @return 返回 VO 实体
   */
  CategoryGoodsVO convertToCategoryGoods(HiolabsGoods goods);

  /**
   * 映射返回 {@link CategoryGoodsVO} - {@link List} 列表数据
   *
   * @param goodsList 原 PO 列表数据
   * @return VO 实体列表
   */
  List<CategoryGoodsVO> convertToCategoryGoodsList(List<HiolabsGoods> goodsList);

  /**
   * 返回主页商品列表
   *
   * @param category 原分类信息
   * @return 商品列表值对象
   */
  @Mappings({
    @Mapping(source = "category.id", target = "id"),
    @Mapping(source = "category.name", target = "name"),
    @Mapping(source = "category.imgUrl", target = "banner"),
    @Mapping(source = "category.PHeight", target = "height")
  })
  HomeCategoryListVO convertToHomeGoodsList(HiolabsCategory category);

  /**
   * 返回主页商品
   *
   * @param goods 原商品对象
   * @return 主页商品
   */
  @IterableMapping(elementTargetType = HiolabsGoods.class)
  List<HomeGoodsListVO> convertToHomeGoods(List<HiolabsGoods> goods);

  /**
   * 返回自身值对象
   *
   * @param goods 原 po 对象
   * @return 自身值对象
   */
  HiolabsGoodsVO convertToVo(HiolabsGoods goods);
  /**
   * 返回自身值对象 list
   *
   * @param goods 原 po 对象
   * @return 自身值对象 list
   */
  List<HiolabsGoodsVO> convertToVoList(List<HiolabsGoods> goods);

  /**
   * 返回足迹商品值对象
   *
   * @param goods 原商品 po 对象
   * @return 足迹值对象
   */
  FootGoodsVO convertToFoodGoods(HiolabsGoods goods);
}
